#include <iostream>
#include <climits>
using namespace std;

struct TreeNode {
  int val;
  TreeNode *left;
  TreeNode *right;
  TreeNode() : val(0), left(nullptr), right(nullptr) {}
  TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
  TreeNode(int x, TreeNode *left, TreeNode *right)
      : val(x), left(left), right(right) {}
};

class Solution {
public:
  bool isValidBST(TreeNode *root) {
    return recurse(root, LLONG_MIN, LLONG_MAX);
  }

  bool recurse(TreeNode *root, long long lower, long long upper) {
    if (!root)
      return true;

    int val = root->val;
    if (lower >= val || upper <= val)
      return false;

    return recurse(root->left, lower, val) && recurse(root->right, val, upper);
  }
};

int main() { cout << LLONG_MAX << endl; }